<?php

/**
 * Botenmarkt Front-end
 * 
 * Domain Objects
 *
 * @category    botenmarkt_front
 * @package     library
 * @subpackage  domainObjects
 * 
 * @author      valerii lazarevych <valeriy.fremar@gmail.com>
 * @copyright   Copyright(c) Fremar ltd.
 * 
 * @license     default
 * @version     12:33:36 PM | Feb 20, 2012
 */

/**
 * Ecard domain Class
 */
class   Ecards_domainObject     extends domainObject
{
    /**
     * Title
     * 
     * @var string $title
     */
    public  $title          =       null;
    
    /**
     * Category
     * 
     * @var EcardCategories_domainObject $category
     */
    public  $category       =       null;
    
    /**
     * Picture url address
     * 
     * @var string $picture_url
     */
    public  $picture_url    =       null;
    
    /**
     * Publish status
     * 
     * @var bool $status
     */
    public  $status         =       null;
    
    /**
     * Send times
     * 
     * @var int $sent
     */
    public  $sent           =       null;
    
    /**
     * Visit times
     * 
     * @var int $visited
     */
    public  $visited        =       null;
    
    /**
     * Date of adding in Unix TimeStamp
     * 
     * @var int
     */
    public  $date_added     =       null;
    
    /**
     * Uses instead $picture_url if it's empty
     * 
     * @var string $defaultUrl
     */
    public static   $defaultUrl     =       null;
    
    /**
     * Increment visit counter on + 1 
     * then save & return it
     * 
     * @return int
     */
    public function visitCounts()
    {
        $this->visited++;
        $this->save();
        
        return $this->visited;
    }
    
    /**
     * Increment sended counter
     * 
     * @return int
     */
    public function sendCounts()
    {
        return  ++$this->sent;
    }
    
    /**
     * Get ecard picture url
     * or use by the default
     * 
     * @return string
     */
    public function pictureUrl()
    {
        if ( !$this->picture_url )
              $this->picture_url    =   self::$defaultUrl;
                        
        return $this->picture_url;
    }
}

